package com.paic.mhis.hcpms.quota.exportword.biz.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.paic.mhis.hcpms.quota.exportword.biz.service.AutoGetFeeMedRelatedService;
import com.paic.mhis.hcpms.quota.exportword.biz.service.AutoGetMedicalFeeService;
import com.paic.mhis.hcpms.quota.exportword.biz.service.MedPerFeeWordReportService;
import com.paic.mhis.hcpms.quota.exportword.biz.service.QueryPerFeeAndTimesService;
import com.paic.mhis.hcpms.quota.exportword.biz.service.WordReportPersonNumAndAverageNumFee;
import com.paic.mhis.hcpms.quota.exportword.biz.service.WordReportService;
import com.paic.mhis.hcpms.quota.exportword.biz.service.WordReportTotalFeeService;
import com.paic.mhis.hcpms.quota.exportword.utils.WordReportCalculateHelper;

@Service("wordReportService")
public class WordReportServiceImpl implements WordReportService {

	@Autowired
	private MedPerFeeWordReportService medPerFeeWordReportService;

	@Autowired
	private AutoGetFeeMedRelatedService autoGetFeeMedRelatedService;

	@Autowired
	private AutoGetMedicalFeeService autoGetMedicalFeeService;

	@Autowired
	private WordReportTotalFeeService wordReportTotalFeeService;

	@Autowired
	private WordReportPersonNumAndAverageNumFee wordReportPersonNumAndAverageNumFee;

	WordReportCalculateHelper calculateHelper = new WordReportCalculateHelper();

	@Autowired
	private QueryPerFeeAndTimesService queryPerFeeAndTimesService;

	// 获取单一机构12个月 平均住院日与日均床日费数据
	@Override
	public Map<String, Object> queryOneOrgYearData(Map<String, Object> mapValue) {
		return medPerFeeWordReportService.querySingleAvgHospBedDaysAndEveBedFeeList(mapValue);
	}

	// 获取月总平均住院日与日均床日费 KPI0006 住院日 KPI0007 日费用
	@Override
	public Map<String, Object> queryKpiData(Map<String, Object> mapValue, Map<String, Object> kpiLimitValue) {
		return medPerFeeWordReportService.queryOverallAvgHospBedDaysAndEveBedFee(mapValue, kpiLimitValue);
	}

	// 获取12个月 总 平均住院日与日均床日费
	@Override
	public Map<String, Object> queryYearKpiData(Map<String, Object> mapValue) {
		return medPerFeeWordReportService.queryOverallAvgHospBedDaysAndEveBedFeeList(mapValue);

	}

	// 获取多等级机构 总平均住院日与日均床日费
	@Override
	public Map<String, Object> queryMoreOrgData(Map<String, Object> mapValue) {

		return medPerFeeWordReportService.queryAvgHospBedDaysAndEveBedCostsCompared(mapValue);

	}

	// 获取单一机构月 平均住院日与日均床日费数据
	@Override
	public Map<String, Object> queryOneOrgData(Map<String, Object> mapValue, Map<String, Object> kpiQuotaLimitMap) {
		return medPerFeeWordReportService.querySingleAvgHospBedDaysAndEveBedFee(mapValue, kpiQuotaLimitMap);
	}

	// 获得住院的总费用相关数据
	@Override
	public Map<String, Object> getHosFeeToWord(Map<String, Object> paramsMap, Map<String, Object> kpiQuotaLimitMap) {

		return autoGetFeeMedRelatedService.getHosFeeToRtf(paramsMap, kpiQuotaLimitMap);
	}

	// 获得门诊的总费用相关数据
	@Override
	public Map<String, Object> getOutFeeToWord(Map<String, Object> paramsMap, Map<String, Object> kpiQuotaLimitMap) {

		return autoGetFeeMedRelatedService.getOutFeeToRtf(paramsMap, kpiQuotaLimitMap);
	}

	// 获得住院的医保费用占比相关数据
	@Override
	public Map<String, Object> getHosMedToWord(Map<String, Object> paramsMap, Map<String, Object> kpiQuotaLimitMap) {

		return autoGetFeeMedRelatedService.getHosMedToRtf(paramsMap, kpiQuotaLimitMap);
	}

	// 获得门诊的医保费用占比相关数据
	@Override
	public Map<String, Object> getOutMedToWord(Map<String, Object> paramsMap, Map<String, Object> kpiQuotaLimitMap) {

		return autoGetFeeMedRelatedService.getOutMedToRtf(paramsMap, kpiQuotaLimitMap);
	}

	@Override
	public Map<String, Object> queryFundRisk(Map<String, Object> mapValue) {
		Map<String, Object> map = new HashMap<String, Object>();
		return map;
	}

	@Override
	public Map<String, Object> queryFundRatioGDP(Map<String, Object> mapValue) {
		Map<String, Object> map = new HashMap<String, Object>();
		List fundList = new ArrayList(12);
		List empList = new ArrayList(12);
		List perList = new ArrayList(12);
		map.put("fund", fundList);
		map.put("emp", empList);
		map.put("per", perList);
		return map;
	}

	/**
	 * 查询各科室费用    1是住院  2是门诊 
	 * @param mapValue
	 * @param visitType
	 * @return
	 */
	@Override
	public Map<String, Object> queryWorkDeptsData(Map<String, Object> mapValue, String visitType) {
		return medPerFeeWordReportService.querySingleInstitutionsDeptCostAnalysis(mapValue, visitType);
	}

	@Override
	public Map<String, Object> getTotalPersonOutNumInfo(Map<String, Object> param, Map<String, Object> kpiQuotaLimitMap) {
		Map<String, Object> map = wordReportPersonNumAndAverageNumFee.getTotalPersonOutNumInfo(param, kpiQuotaLimitMap);
		return map;
	}

	@Override
	public Map<String, Object> getTotalPersonOutNumAverageFee(Map<String, Object> param,
			Map<String, Object> kpiQuotaLimitMap) {
		Map<String, Object> map = wordReportPersonNumAndAverageNumFee.getTotalPersonOutNumAverageFee(param,
				kpiQuotaLimitMap);
		return map;

	}

	@Override
	public Map<String, Object> getTotalPersonHospNumInfo(Map<String, Object> param, Map<String, Object> kpiQuotaLimitMap) {
		Map<String, Object> map = wordReportPersonNumAndAverageNumFee
				.getTotalPersonHospNumInfo(param, kpiQuotaLimitMap);
		return map;
	}

	@Override
	public Map<String, Object> getTotalPersonHospNumAverageFee(Map<String, Object> param,
			Map<String, Object> kpiQuotaLimitMap) {
		Map<String, Object> map = wordReportPersonNumAndAverageNumFee.getTotalPersonHospNumAverageFee(param,
				kpiQuotaLimitMap);
		return map;
	}

	// 第二部分

	@Override
	public Map<String, Object> getBetweenPersonOutNumAverageFee(Map<String, Object> paramsMap) {
		return this.queryPerFeeAndTimesService.getOutTableData(paramsMap);
	}

	@Override
	public Map<String, Object> getBetweenPersonHospNumAverageFee(Map<String, Object> paramsMap) {
		return this.queryPerFeeAndTimesService.getHosTableData(paramsMap);
	}

	// ----------------nick---------------------
	@Override
	public Map<String, Object> getPercentPredict(Map<String, Object> param, Map<String, Object> kpiQuotaLimitMap) {

		Map<String, Object> map = wordReportTotalFeeService.getPercentPredict(param, kpiQuotaLimitMap);

		return map;
	}

	@Override
	public Map<String, Object> getTotalFeePredict(Map<String, Object> param, Map<String, Object> kpiQuotaLimitMap) {
		Map<String, Object> map = wordReportTotalFeeService.getTotalFeePredict(param, kpiQuotaLimitMap);
		return map;
	}

	// ******1模块*****************
	@Override
	public Map<String, Object> queryOutData(Map<String, Object> mapValue, Map<String, Object> kpiQuotaLimitMap) {

		return medPerFeeWordReportService.queryOrgHospCostAndTimesNum(mapValue, kpiQuotaLimitMap);
	}

	// ***********************
	@Override
	public Map<String, Object> queryOutYearData(Map<String, Object> mapValue) {
		return medPerFeeWordReportService.queryGeneralOutpatientNumberAndTimesCostList(mapValue);
	}

	// ***************************KPI10 人数 kpi01 费用

	@Override
	public Map<String, Object> queryOneOutData(Map<String, Object> mapValue, Map<String, Object> kpiQuotaLimitMap) {
		return medPerFeeWordReportService.querySingleAgencyOutpatientNumAndTimesCost(mapValue, kpiQuotaLimitMap);
	}

	@Override
	public Map<String, Object> queryOneOutYearData(Map<String, Object> mapValue, Map<String, Object> kpiQuotaLimitMap) {
		return medPerFeeWordReportService.querySingleAgencyOutpatientNumAndTimesCostList(mapValue, kpiQuotaLimitMap);
	}

	@Override
	public Map<String, Object> queryMorOrgOutData(Map<String, Object> mapValue) {
		return medPerFeeWordReportService.queryMoreOrgHospCostAndTimesNumList(mapValue);
	}

	/**
	 * Description:第一部分住院药品费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getHosMedicalFeeToWord(Map<String, Object> paramsMap, Map<String, Object> kpiLimitValue) {
		return autoGetMedicalFeeService.getHosMedicalFeeToWord(paramsMap, kpiLimitValue);
	}

	/**
	 * Description: 第一部住院其他费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getHosOthersFeeToWord(Map<String, Object> paramsMap, Map<String, Object> kpiLimitValue) {
		return autoGetMedicalFeeService.getHosOthersFeeToWord(paramsMap, kpiLimitValue);
	}

	/**
	 * Description: 第一部分门诊药品费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getOutMedicalFeeToWord(Map<String, Object> paramsMap, Map<String, Object> kpiLimitValue) {
		return autoGetMedicalFeeService.getOutMedicalFeeToWord(paramsMap, kpiLimitValue);
	}

	/**
	 * Description: 第一部分门诊其他费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getOutOthersFeeToWord(Map<String, Object> paramsMap, Map<String, Object> kpiLimitValue) {
		return autoGetMedicalFeeService.getOutOthersFeeToWord(paramsMap, kpiLimitValue);
	}

	/**
	 * Description: 第二部分住院不同等级费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getHosGradeFeeToWordByGrade(Map<String, Object> paramsMap) {
		return autoGetMedicalFeeService.getHosGradeFeeToWordByGrade(paramsMap);
	}

	/**
	 * Description: 第二部分门诊不同等级费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getOutGradeFeeToWordByGrade(Map<String, Object> paramsMap) {
		return autoGetMedicalFeeService.getOutGradeFeeToWordByGrade(paramsMap);
	}

	/**
	 * Description: 第三部分单一机构住院药品费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getHosMedicalFeeToWordByOrg(Map<String, Object> paramsMap,
			Map<String, Object> kpiLimitValue) {
		return autoGetMedicalFeeService.getHosMedicalFeeToWordByOrg(paramsMap, kpiLimitValue);
	}

	/**
	 * Description:第三部分单一机构住院其他费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getHosOthersFeeToWordByOrg(Map<String, Object> paramsMap,
			Map<String, Object> kpiLimitValue) {
		return autoGetMedicalFeeService.getHosOthersFeeToWordByOrg(paramsMap, kpiLimitValue);
	}

	/**
	 * Description: 第三部分单一机构门诊药品费用
	 * 
	 * @param paramsMap
	 * @return
	 */
	public Map<String, Object> getOutMedicalFeeToWordByOrg(Map<String, Object> paramsMap,
			Map<String, Object> kpiLimitValue) {
		return autoGetMedicalFeeService.getOutMedicalFeeToWordByOrg(paramsMap, kpiLimitValue);

	}

	/**
	 * Description: 第三部分单一机构门诊其他费用
	 * 
	 * @param paramsMap
	 *            paramsMap
	 * @return
	 */
	public Map<String, Object> getOutOthersFeeToWordByOrg(Map<String, Object> paramsMap,
			Map<String, Object> kpiLimitValue) {
		return autoGetMedicalFeeService.getOutOthersFeeToWordByOrg(paramsMap, kpiLimitValue);
	}

	/**
	 * Decription:2.1月度审查相关测试数据
	 */
	@Override
	public Map<String, Object> getMonthCheckFee(Map<String, Object> paramsMap) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		// 1.费用审查相关键对应的值
		resultMap = wordReportTotalFeeService.getMonthCheckFee(paramsMap);
		return resultMap;
	}
}